<template>
	<view class="content">
			<uni-forms ref="baseForm" :modelValue="queryForm">
				<view class="top">
				<view>
					<uni-easyinput v-model="queryForm.key" placeholder="请输入药名" />
				</view>
				<view class="uni-ml-5">
					<uni-data-select
					v-model="queryForm.type"
					  :localdata="range"
					></uni-data-select>
				</view>
				<view class="uni-ml-5">
					<button @click="seachBtn()">查询</button>
				</view>	
				</view>
				<hr />
			</uni-forms>
			<view class="box uni-ml-5" v-for="item in drugsList" :key="item.ID">
				<view class="boxone">
					<view class="uni-mt-5 uni-mb-5" style="color: #207FAD;">
					<text>{{ item.name}}</text>
					<text>{{ title }}</text>
				</view>
				<view class="">
					<text>药品用法：{{item.yongfa}}</text>
					<text>药品频次：{{item.pinci}}</text>
				</view>
				<view class="">
					<text>药品用量：{{item.yongliang}}</text>
					<text>备注：{{item.beizhu}}</text>
				</view>
				</view>
				<view class="boxtwo uni-mt-5">
					<view>
						<button class="greenBold" @click='goeditBiood(item)'><i class="iconfont icon-jiahao"></i> 选择</button>
					</view>
				</view>
				<hr class="uni-mt-7"/>
			</view>
			
	</view>
</template>

<script>
	import {getDrugsList} from '@/api/index.js'
	export default {
		data() {
			return {
				title:'高血压',
				msg:'',
				queryForm:{
					type:'1',
					key:''
				},
				drugsList:[],
				range:[{text:'高血压',value:'1'},{text:'糖尿病',value:'2'},{text:'精神障碍',value:'3'}]
			}
		},
		onLoad(option) {
			this.queryForm.type = option.msg
			getDrugsList(this.queryForm).then(res=>{
				this.drugsList = res
			})
		},
		methods: {
			seachBtn(){
				getDrugsList(this.queryForm).then(res=>{
					this.drugsList = res
					if(this.queryForm.type=='1'){
						this.title = '高血压'
					}else if(this.queryForm.type=='2'){
						this.title = '糖尿病'
					}else if(this.queryForm.type=='3'){
						this.title = '精神障碍'
					}
				})
			},
			goeditBiood(val){
				// 在当前页面跳转到上一页，并携带参数
				let pages = getCurrentPages(); // 当前页页⾯实例
				let nowPage = pages[pages.length -1]; //当前页⾯实例
				let prevPage = pages[pages.length -2]; // 上一页面实例
				prevPage.$vm.prevDateFun(val) // 调用上一页 定义的方法
				uni.navigateBack({
				  delta:1 // 可以不写，默认值为 1
				})
			}
		}
	}
</script>

<style lang="scss">
	.box{
		.boxone{
			text{
			display: inline-block;
			width:50% ;
			font-size: 26rpx;
			}
			
		}
	.boxtwo{
		width: 90%;
		display: flex;
		justify-content: space-between;
		button{
			width: 140rpx;
			font-size: 26rpx;
			border: none !important;
		}
		i{
			font-size: 18rpx
		}
	}
	}
	.content{
		width: 100wh;
		padding: 0 15rpx;
		box-sizing:border-box;
	}
	.top{
		margin: 10rpx 0;
		display: flex;
		align-items: center;
		:deep(.uni-stat__select) {
			width: 90px !important;
		}
		.uni-easyinput{
			width: 100px !important;
		}
		button{
			width: 120rpx;
			font-size: 20rpx;
			border-radius: 100rpx;
			background-color: #009316;
			color: white;
		}
	}
	hr{
		width: 100%;
		background-color: #dfdfdf;
		border:1px solid #dfdfdf;
		border-bottom:none ;
	}
	.green{
		background-color: #009316;
		color: white;
	}
	.greenBold{
		background-color: #008989;
		color: white;
	}
	.White{
		padding: 2rpx 0;
	}
</style>
